<template>
	<div class="operator-record-index">
		<div></div>
		<el-divider></el-divider>
		<el-table :data="tableData" style="width: 100%">
			<el-table-column prop="staffId" label="用户ID">
			</el-table-column>
			<el-table-column prop="name" label="操作类型">
				<template slot-scope="scope">
					{{scope.row.agreementType === '1' ? "同意" : scope.row.agreementType === '0' ? "撤销" : ""}}
				</template>
			</el-table-column>
			<el-table-column prop="createdAt" label="时间">
			</el-table-column>
		</el-table>
		<el-pagination style="margin-top: 15px;text-align: right;" :current-page="page.pageNo"
			:page-sizes="[10, 20, 30, 50, 100]" :page-size="page.pageSize"
			layout="total, sizes, prev, pager, next, jumper" :total="page.total" @size-change="handleSizeChange"
			@current-change="handleCurrentChange" />
	</div>
</template>

<script>
	import {
		fetchPrivacyProtocolOperateList,
	} from '@/api/privacyProtocol'

	export default {
		props: {
			policyId: {
				type: Number,
				default: undefined
			},
		},
		data() {
			return {
				key: "",
				tableData: [],
				page: {
					pageNo: 1,
					pageSize: 10,
					total: 0
				},
			}
		},
		mounted() {
			this.go2Query()
		},
		methods: {
			handleSizeChange(val) {
				this.page.pageSize = val
				this.go2Query()
			},
			handleCurrentChange(val) {
				this.page.pageNo = val
				this.go2Query()
			},
			go2Query() {
				const loading = this.$loading({
					lock: true,
					text: '加载中',
					spinner: 'el-icon-loading',
					background: 'rgba(0, 0, 0, 0.7)'
				})
				const params = {
					pageNo: this.page.pageNo,
					pageNoSize: this.page.pageSize,
					policyId: this.policyId
				}
				fetchPrivacyProtocolOperateList(params).then((res) => {
					loading.close()
					if (res.code === 0) {
						this.tableData = res.data
						this.page.total = res.total
					}
				}).catch((error) => {
					loading.close()
					console.log(error)
				})
			},
		},
	}
</script>

<style lang="scss">
	.operator-record-index {}
</style>